#ifndef _BARTER_SERVER_SQLITEDATABASEDRIVER_H_
#define _BARTER_SERVER_SQLITEDATABASEDRIVER_H_

#include "IDatabase.h"

#include "sqlite3.h"

class SQLiteDatabaseDriver : public IDatabase
{
private:
	sqlite3* dbPtr;
public:
	SQLiteDatabaseDriver();
	~SQLiteDatabaseDriver();
	bool Open(DatabaseConnectionInfo*);
	void Close();
	IDBQueryResult* Query(DBQuery&);
	void Exec(DBQuery&);
	void BatchExec(std::string);
};

class SQLiteDBQueryResult : public IDBQueryResult
{
private:
	sqlite3* DBHandle;
	sqlite3_stmt* Handle;
	std::map<const std::string, unsigned int> Names;
public:
	SQLiteDBQueryResult(sqlite3*, sqlite3_stmt*);
	~SQLiteDBQueryResult();
	virtual long GetDoubleWord(std::string);
	virtual long long GetQuadWord(std::string);
	virtual std::string GetString(std::string);
	virtual const char* GetBinaryData(std::string, unsigned long& size); // size: 32-bit number of the binary data size
	virtual bool NextRow();
};


extern "C"
{
	void* InitModule(void*);
	void* DestroyModule(void*);
}

#endif // _BARTER_SERVER_SQLITEDATABASEDRIVER_H_
